﻿namespace WMS6.Web.Analytics
{
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.UserControls;

    public class InvoiceRptQuery : BasePage
    {
        protected Button btnSearch;
        protected DropDownList ddlAmountSubmit;
        protected DropDownList ddlAmountSubmitDescr;
        protected DropDownList ddlInvoiceIDDescr;
        protected DropDownList ddlInvoiceSubmit;
        protected DropDownList ddlInvoiceSubmitDescr;
        protected DropDownList ddlOwnerIDOper;
        protected DropDownList ddlStatementID;
        protected DropDownList ddlStatusDescr;
        protected HtmlForm F15620;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlHead Head1;
        protected HtmlImage imgOwnerID;
        protected Label lblAmountSubmit;
        protected Label lblEndDate;
        protected Label lblInvoiceID;
        protected Label lblInvoiceSubmit;
        protected Label lblOwnerID;
        protected Label lblQuery;
        protected Label lblStartDate;
        protected Label lblStatementID;
        protected Label lblStatus;
        protected MultipleSelectControl MSCStatus;
        protected HtmlLink mycss;
        protected TextBox txtEndDate;
        protected TextBox txtInvoiceID;
        protected TextBox txtOwnerID;
        protected TextBox txtStartDate;
        protected TextBox txtStatementID;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("InvoiceRptList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("InvoiceRptList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void LoadData()
        {
            base.InitQueryDDL(this.ddlInvoiceIDDescr, 0);
            base.InitQueryDDL(this.ddlOwnerIDOper, 0);
            base.InitQueryDDL(this.ddlStatusDescr, 0);
            base.InitQueryDDL(this.ddlStatementID, 0);
            base.InitQueryDDL(this.ddlInvoiceSubmitDescr, 0);
            base.InitQueryDDL(this.ddlAmountSubmitDescr, 0);
            this.ddlStatusDescr.SelectedValue = "One Of";
            base.BindData2DDLBySysCode(this.MSCStatus, "InvoiceStatus");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
            }
        }

        public string AmountSubmit
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlAmountSubmit.SelectedValue))
                {
                    return base.GetParamsString(this.ddlAmountSubmit.SelectedValue, this.ddlInvoiceSubmitDescr.SelectedValue);
                }
                return "";
            }
        }

        public string EndDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtEndDate.Text.Trim()))
                {
                    return (Convert.ToDateTime(this.txtEndDate.Text).ToString("yyyy-MM-dd") + " 23:59:59");
                }
                return "";
            }
        }

        public string InvoiceID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtInvoiceID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtInvoiceID.Text.Trim(), this.ddlInvoiceIDDescr.SelectedValue);
                }
                return "";
            }
        }

        public string InvoiceStatus
        {
            get
            {
                if (!string.IsNullOrEmpty(this.MSCStatus.ReturnValue))
                {
                    return base.GetParamsString(this.MSCStatus.ReturnValue, this.ddlStatusDescr.SelectedValue);
                }
                return "";
            }
        }

        public string InvoiceSubmit
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlInvoiceSubmit.SelectedValue))
                {
                    return base.GetParamsString(this.ddlInvoiceSubmit.SelectedValue, this.ddlInvoiceSubmitDescr.SelectedValue);
                }
                return "";
            }
        }

        public string OwnerID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtOwnerID.Text.Trim(), this.ddlOwnerIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string StartDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim()))
                {
                    return (Convert.ToDateTime(this.txtStartDate.Text).ToString("yyyy-MM-dd") + " 00:00:00");
                }
                return "";
            }
        }

        public string StatementID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtStatementID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtStatementID.Text.Trim(), this.ddlStatementID.SelectedValue);
                }
                return "";
            }
        }
    }
}

